<template>
  <div v-if="promotion" id="goods-exchange">
    <div class="prom-bar-container">
      <div class="prom-price">{{ promotion.exchange_point }}积分 + ¥<em>{{ promotion.exchange_money | unitPrice('', 'before') }}</em>.{{ promotion.exchange_money | unitPrice('', 'after') }}</div>
	    <div class="msg">
        <div class="text">
          <span></span>
          <del class="old-price">¥{{ promotion.goods_price | unitPrice }}</del>
        </div>
        <div class="text">
          <span class="icon exchange">积分兑换</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  export default {
    name: 'goods-exchange',
    props: ['promotions'],
    computed: {
      promotion() {
        const { promotions } = this
        if (!promotions || !promotions.length) return false
        let prom = promotions.filter(item => item.exchange)
        if (prom[0]) return prom[0].exchange
        return false
      }
    }
  }
</script>

<style type="text/scss" lang="scss" scoped>
  @import "../../assets/styles/color";
  .prom-bar-container {
    position: relative;
    display: flex;
    align-items: center;
    z-index: 10;
    height: 49px;
    color: #fff;
    background: url(../../assets/images/background-promotion-bar.png) no-repeat,-webkit-linear-gradient(top,#fc5997,#ef4747);
    background-size: 259px,100%;
    justify-content: space-between;
    .prom-price {
      margin: 0 10px;
      font-size: 14px;
      font-weight: 700;
      em {
        font-size: 24px;
      }
    }
    .msg {
      margin-right: 10px;
      font-size: 12px;
	    text-align: center;
      .icon {
        position: relative;
        display: inline-block;
        margin: -2px 3px 0 0;
        padding: 0 3px 0 18px;
        height: 15px;
        vertical-align: middle;
        line-height: 15px;
        font-size: 10px;
        &.exchange::before {
          background: #fff url() no-repeat 50%;
          background-size: 12px
        }
        &::before {
          content: "";
          position: absolute;
          left: 0;
          top: 0;
          width: 15px;
          height: 15px;
          border-top-left-radius: 1px;
          border-bottom-left-radius: 1px;
        }
        &::after {
          content: "";
          display: block;
          border: 1px solid #fff;
          position: absolute;
          top: 0;
          left: 0;
          pointer-events: none;
          bottom: 0;
          right: 0;
          border-radius: 2px;
        }
      }
    }
    .count-down {
      position: absolute;
      right: 0;
      top: 0;
      min-width: 116px;
      height: 100%;
      text-align: center;
      background-color: #f8f8f8;
      .count-down-text {
        font-size: 10px;
        color: #666;
      }
      .count-down-times {
        margin: 5px 0 2px;
        font-size: 14px;
        color: $color-main;
      }
    }
  }
</style>
